layui.define(['table', 'form'], function(exports){
  var $ = layui.$
  ,table = layui.table
  ,form = layui.form;

  //用户管理
  table.render({
    elem: '#LAY-user-manage'
    ,url: 'getUsers' //模拟接口
    ,cols: [[
      {type: 'checkbox', fixed: 'left'}
      ,{field: 'uId', width: 100, title: 'ID', sort: true}
      ,{field: 'uName', title: '用户名', minWidth: 100}
      ,{field: 'uPic', title: '头像', width: 100, templet: '#imgTpl'}
      ,{field: 'uTel', title: '手机'}
      ,{field: 'uEmail', title: '邮箱'}
      ,{field: 'uSex', width: 80, title: '性别', templet: '#sexTpl'}
      ,{field: 'uIp', title: 'IP'}
      ,{field: 'uRegtime', title: '加入时间', sort: true}
      ,{title: '操作', width: 150, align:'center', fixed: 'right', toolbar: '#table-useradmin-webuser'}
    ]]
    ,page: true
    ,limit: 30
    ,height: 'full-220'
    ,text: {none: '一条数据也没有^_^'}
  });
  
  //监听工具条
  table.on('tool(LAY-user-manage)', function(obj){
    var data = obj.data,
        ids = [];
    ids.push(data.uId);
    if(obj.event === 'del'){
      layer.prompt({
        formType: 1
        ,title: '敏感操作，请验证密码'
      }, function(value, index){
        if (checkpass(value)) {
            layer.close(index);
            layer.confirm('真的删除当前用户么？', function (index) {
                layer.close(index);
                $.ajax({
                    url: "delUser",
                    dataType: "json",
                    type: "post",
                    data: {
                        ids: ids
                    },
                    success: function (data) {
                        if (data.status == 1) {
                            layer.msg('删除成功', {
                                icon: 1
                                , time: 1000
                            }, function () {
                                obj.del();
                            });
                        }
                        else if (data.status == 0) {
                            layer.msg('删除失败', {
                                icon: 0
                                , time: 1000
                            });
                        }
                    },
                    error: function (result) {
                        console.log(result);
                        alert("系统繁忙！");
                    }
                });
            });
        }
      });
    } else if(obj.event === 'edit'){
      var tr = $(obj.tr);

      var index = layer.open({
        type: 2
        ,title: '编辑用户'
        ,content: 'userEdit?uId='+data.uId
        ,maxmin: true
        ,area: ['500px', '650px']
        ,btn: ['确定', '取消']
        ,yes: function(index, layero){
          var iframeWindow = window['layui-layer-iframe'+ index]
          ,submitID = 'LAY-user-front-submit'
          ,submit = layero.find('iframe').contents().find('#'+ submitID);

          //监听提交
          iframeWindow.layui.form.on('submit('+ submitID +')', function(data){
            var field = data.field; //获取提交的字段
            
            //提交 Ajax 成功后，静态更新表格中的数据
            $.ajax({
                  url: "editUser",
                  dataType: "json",
                  type: "post",
                  data: field,
                  success: function (data) {
                      if (data.status == 1) {
                          layer.msg('编辑成功', {
                              icon: 1
                              , time: 1000
                          }, function () {
                              layer.close(index); //关闭弹层
                              table.reload('LAY-user-manage'); //数据刷新
                          });
                      }
                      else if (data.status == 0) {
                          layer.msg('编辑失败', {
                              icon: 0
                              , time: 1000
                          });
                      }
                  },
                  error: function (result) {
                      console.log(result);
                      alert("系统繁忙！");
                  }
              });
          });  
          
          submit.trigger('click');
        }
        ,success: function(layero, index){
          
        }
      });
      //如果手机端，全屏显示
      if(window.innerWidth <= 768) {
          layui.layer.full(index);
          setTimeout(function () {
              layui.layer.tips('点击此处返回', '.layui-layer-setwin .layui-layer-close', {
                  tips: 3
              });
          }, 500)
      }
    }
  });

 //学校管理
  table.render({
    elem: '#LAY-school-manage'
    ,url: 'getSchools'
    ,cols: [[
      {type: 'checkbox', fixed: 'left'}
      ,{field: 'sId', width: 100, title: 'ID', sort: true}
      ,{field: 'sName', title: '学校名', minWidth: 100, sort: true}
      ,{field: 'sPic', title: '学校图片', width: 100, templet: '#imgTpl'}
      ,{field: 'sPosition', title: '地理位置'}
      ,{field: 'sPort', title: '定位接口'}
      ,{field: 'sIntroduce', title: '学校简介'}
      ,{title: '操作', width: 150, align:'center', fixed: 'right', toolbar: '#table-useradmin-webuser'}
    ]]
    ,page: true
    ,limit: 30
    ,height: 'full-220'
    ,text: {none: '一条数据也没有^_^'}
  });

  //监听工具条
  table.on('tool(LAY-school-manage)', function(obj){
    var data = obj.data,
        ids = [];
    ids.push(data.sId);
    if(obj.event === 'del'){
      layer.prompt({
        formType: 1
        ,title: '敏感操作，请验证密码'
      }, function(value, index){
        if (checkpass(value)) {
            layer.close(index);
            layer.confirm('真的删除当前学校么？', function (index) {
                layer.close(index);
                $.ajax({
                    url: "delSchool",
                    dataType: "json",
                    type: "post",
                    data: {
                        ids: ids
                    },
                    success: function (data) {
                        if (data.status == 1) {
                            layer.msg('删除成功', {
                                icon: 1
                                , time: 1000
                            }, function () {
                                obj.del();
                            });
                        }
                        else if (data.status == 0) {
                            layer.msg('删除失败', {
                                icon: 0
                                , time: 1000
                            });
                        }
                    },
                    error: function (result) {
                        console.log(result);
                        alert("系统繁忙！");
                    }
                });
            });
        }
      });
    } else if(obj.event === 'edit'){
      var tr = $(obj.tr);

      var index = top.layer.open({
        type: 2
        ,title: '编辑学校'
        ,content: 'schoolEdit?sId='+data.sId
        ,maxmin: true
        ,area: ['700px', '650px']
        ,btn: ['确定', '取消']
        ,yes: function(index, layero){
          var iframeWindow = top.window['layui-layer-iframe'+ index]
          ,submitID = 'LAY-front-submit'
          ,submit = layero.find('iframe').contents().find('#'+ submitID);

          //监听提交
          iframeWindow.layui.form.on('submit('+ submitID +')', function(data){
            var field = data.field; //获取提交的字段

            //提交 Ajax 成功后，静态更新表格中的数据
            $.ajax({
                  url: "editSchool",
                  dataType: "json",
                  type: "post",
                  data: field,
                  success: function (data) {
                      if (data.status == 1) {
                          top.layer.msg('编辑成功', {
                              icon: 1
                              , time: 1000
                          }, function () {
                              top.layer.close(index); //关闭弹层
                              table.reload('LAY-school-manage'); //数据刷新
                          });
                      }
                      else if (data.status == 0) {
                          top.layer.msg('编辑失败', {
                              icon: 0
                              , time: 1000
                          });
                      }
                  },
                  error: function (result) {
                      console.log(result);
                      alert("系统繁忙！");
                  }
              });
          });

          submit.trigger('click');
        }
        ,success: function(layero, index){

        }
      });
      //如果手机端，全屏显示
      if(window.innerWidth <= 768) {
          top.layui.layer.full(index);
          setTimeout(function () {
              top.layui.layer.tips('点击此处返回', '.layui-layer-setwin .layui-layer-close', {
                  tips: 3
              });
          }, 500)
      }
    } else if(obj.event === 'pic'){
      var tr = $(obj.tr);

      var index = top.layer.open({
        type: 2
        ,title: '学校地图'
        ,content: 'pictures?flag=2&id='+data.sId
        ,maxmin: true
        ,area: ['1000px', '650px']
      });
      //如果手机端，全屏显示
      if(window.innerWidth <= 768) {
          top.layui.layer.full(index);
          setTimeout(function () {
              top.layui.layer.tips('点击此处返回', '.layui-layer-setwin .layui-layer-close', {
                  tips: 3
              });
          }, 500)
      }
    }
  });

 //首页推荐
  table.render({
    elem: '#LAY-ads-manage'
    ,url: 'getAds'
    ,cols: [[
      {type: 'checkbox', fixed: 'left'}
      ,{field: 'iId', width: 100, title: 'ID', sort: true}
      ,{field: 'iDesc', title: '描述', minWidth: 100, sort: true}
      ,{field: 'iPic', title: '图片', width: 100, templet: '#imgTpl'}
      ,{field: 'iLink', title: '链接地址'}
      ,{field: 'iIndex', title: '显示顺序', sort: true}
      ,{field: 'iDisplay', title: '是否展示', templet: '#flag', sort: true}
      ,{field: 'iTime', title: '添加时间', sort: true}
      ,{title: '操作', width: 150, align:'center', fixed: 'right', toolbar: '#table-useradmin-webuser'}
    ]]
    ,page: true
    ,limit: 30
    ,height: 'full-220'
    ,text: {none: '一条数据也没有^_^'}
  });

  //监听工具条
  table.on('tool(LAY-ads-manage)', function(obj){
    var data = obj.data,
        ids = [];
    ids.push(data.iId);
    if(obj.event === 'del'){
      layer.prompt({
        formType: 1
        ,title: '敏感操作，请验证密码'
      }, function(value, index){
        if (checkpass(value)) {
            layer.close(index);
            layer.confirm('真的删除当前推荐么？', function (index) {
                layer.close(index);
                $.ajax({
                    url: "delAds",
                    dataType: "json",
                    type: "post",
                    data: {
                        ids: ids
                    },
                    success: function (data) {
                        if (data.status == 1) {
                            layer.msg('删除成功', {
                                icon: 1
                                , time: 1000
                            }, function () {
                                obj.del();
                            });
                        }
                        else if (data.status == 0) {
                            layer.msg('删除失败', {
                                icon: 0
                                , time: 1000
                            });
                        }
                    },
                    error: function (result) {
                        console.log(result);
                        alert("系统繁忙！");
                    }
                });
            });
        }
      });
    } else if(obj.event === 'edit'){
      var tr = $(obj.tr);

      var index = top.layer.open({
        type: 2
        ,title: '编辑推荐'
        ,content: 'adsEdit?iId='+data.iId
        ,maxmin: true
        ,area: ['700px', '650px']
        ,btn: ['确定', '取消']
        ,yes: function(index, layero){
          var iframeWindow = top.window['layui-layer-iframe'+ index]
          ,submitID = 'LAY-front-submit'
          ,submit = layero.find('iframe').contents().find('#'+ submitID);

          //监听提交
          iframeWindow.layui.form.on('submit('+ submitID +')', function(data){
            var field = data.field; //获取提交的字段

            //提交 Ajax 成功后，静态更新表格中的数据
            $.ajax({
                  url: "editAds",
                  dataType: "json",
                  type: "post",
                  data: field,
                  success: function (data) {
                      if (data.status == 1) {
                          top.layer.msg('编辑成功', {
                              icon: 1
                              , time: 1000
                          }, function () {
                              top.layer.close(index); //关闭弹层
                              table.reload('LAY-ads-manage'); //数据刷新
                          });
                      }
                      else if (data.status == 0) {
                          top.layer.msg('编辑失败', {
                              icon: 0
                              , time: 1000
                          });
                      }
                  },
                  error: function (result) {
                      console.log(result);
                      alert("系统繁忙！");
                  }
              });
          });

          submit.trigger('click');
        }
        ,success: function(layero, index){

        }
      });
      //如果手机端，全屏显示
      if(window.innerWidth <= 768) {
          top.layui.layer.full(index);
          setTimeout(function () {
              top.layui.layer.tips('点击此处返回', '.layui-layer-setwin .layui-layer-close', {
                  tips: 3
              });
          }, 500)
      }
    }
  });

  //景点管理
  table.render({
        elem: '#LAY-view-manage'
        ,url: 'getViews' //模拟接口
        ,cols: [[
            {type: 'checkbox', fixed: 'left'}
            ,{field: 'vId', width: 70, title: 'ID', sort: true}
            ,{field: 'vName', title: '景点名', minWidth: 100, sort: true}
            ,{field: 'schoolname', title: '关联学校', sort: true}
            ,{field: 'vFlag', title: '景点分类', sort: true, templet: '#flagTpl'}
            ,{field: 'vHot', title: '热度', sort: true}
            ,{field: 'vDescribe', minWidth: 100, title: '景点描述'}
            ,{field: 'vPosition', title: '地理位置'}
            ,{field: 'vSpecial', title: '景点特色'}
            ,{field: 'vRoute', title: '路线定制'}
            ,{field: 'vStrategy', title: '景点攻略'}
            ,{field: 'vEat', title: '饮食住行'}
            ,{title: '操作', width: 150, align:'center', fixed: 'right', toolbar: '#table-useradmin-webuser'}
        ]]
        ,page: true
        ,limit: 30
        ,height: 'full-220'
        ,text: {none: '一条数据也没有^_^'}
    });

  //监听工具条
  table.on('tool(LAY-view-manage)', function(obj){
        var data = obj.data,
            ids = [];
        ids.push(data.vId);
        if(obj.event === 'del'){
            layer.prompt({
                formType: 1
                ,title: '敏感操作，请验证密码'
            }, function(value, index){
                if (checkpass(value)) {
                    layer.close(index);
                    layer.confirm('真的删除当前景点么？', function (index) {
                        layer.close(index);
                        $.ajax({
                            url: "delView",
                            dataType: "json",
                            type: "post",
                            data: {
                                ids: ids
                            },
                            success: function (data) {
                                if (data.status == 1) {
                                    layer.msg('删除成功', {
                                        icon: 1
                                        , time: 1000
                                    }, function () {
                                        obj.del();
                                    });
                                }
                                else if (data.status == 0) {
                                    layer.msg('删除失败', {
                                        icon: 0
                                        , time: 1000
                                    });
                                }
                            },
                            error: function (result) {
                                console.log(result);
                                alert("系统繁忙！");
                            }
                        });
                    });
                }
            });
        } else if(obj.event === 'edit'){
            var tr = $(obj.tr);

            var index = layer.open({
                type: 2
                ,title: '编辑景点'
                ,content: 'viewEdit?vId='+data.vId
                ,maxmin: true
                ,area: ['600px', '650px']
                ,btn: ['确定', '取消']
                ,yes: function(index, layero){
                    var iframeWindow = window['layui-layer-iframe'+ index]
                        ,submitID = 'LAY-front-submit'
                        ,submit = layero.find('iframe').contents().find('#'+ submitID);

                    //监听提交
                    iframeWindow.layui.form.on('submit('+ submitID +')', function(data){
                        var field = data.field; //获取提交的字段

                        //提交 Ajax 成功后，静态更新表格中的数据
                        $.ajax({
                            url: "editView",
                            dataType: "json",
                            type: "post",
                            data: field,
                            success: function (data) {
                                if (data.status == 1) {
                                    layer.msg('编辑成功', {
                                        icon: 1
                                        , time: 1000
                                    }, function () {
                                        layer.close(index); //关闭弹层
                                        table.reload('LAY-view-manage'); //数据刷新
                                    });
                                }
                                else if (data.status == 0) {
                                    layer.msg('编辑失败', {
                                        icon: 0
                                        , time: 1000
                                    });
                                }
                            },
                            error: function (result) {
                                console.log(result);
                                alert("系统繁忙！");
                            }
                        });
                    });

                    submit.trigger('click');
                }
                ,success: function(layero, index){

                }
            });
            //如果手机端，全屏显示
            if(window.innerWidth <= 768) {
                layui.layer.full(index);
                setTimeout(function () {
                    layui.layer.tips('点击此处返回', '.layui-layer-setwin .layui-layer-close', {
                        tips: 3
                    });
                }, 500)
            }
        }else if(obj.event === 'pic'){
            var tr = $(obj.tr);

            var index = top.layer.open({
                type: 2
                ,title: '景点图片'
                ,content: 'pictures?flag=1&id='+data.vId
                ,maxmin: true
                ,area: ['1000px', '650px']
            });
            //如果手机端，全屏显示
            if(window.innerWidth <= 768) {
                top.layui.layer.full(index);
                setTimeout(function () {
                    top.layui.layer.tips('点击此处返回', '.layui-layer-setwin .layui-layer-close', {
                        tips: 3
                    });
                }, 500)
            }
        }
    });

  //管理员管理
  table.render({
        elem: '#LAY-role-manage'
        ,url: 'getRoles'
        ,cols: [[
            {type: 'checkbox', fixed: 'left'}
            ,{field: 'aId', width: 70, title: 'ID', sort: true}
            ,{field: 'aUsername', title: '用户名', minWidth: 100, sort: true}
            ,{field: 'aRealname', title: '真实姓名', sort: true}
            ,{field: 'aPhone', minWidth: 100, title: '手机号'}
            ,{field: 'aEmail', title: '邮箱'}
            ,{field: 'aRecent', title: '最近登录', sort: true}
            ,{field: 'aIp', title: 'IP'}
            ,{title: '操作', width: 150, align:'center', fixed: 'right', toolbar: '#table-useradmin-webuser'}
        ]]
        ,page: true
        ,limit: 30
        ,height: 'full-220'
        ,text: {none: '一条数据也没有^_^'}
    });

  //监听工具条
  table.on('tool(LAY-role-manage)', function(obj){
        var data = obj.data,
            ids = [];
        ids.push(data.aId);
        if(obj.event === 'del'){
            layer.prompt({
                formType: 1
                ,title: '敏感操作，请验证密码'
            }, function(value, index){
                if (checkpass(value)) {
                    layer.close(index);
                    layer.confirm('真的删除当前管理员么？', function (index) {
                        layer.close(index);
                        $.ajax({
                            url: "delRole",
                            dataType: "json",
                            type: "post",
                            data: {
                                ids: ids
                            },
                            success: function (data) {
                                if (data.status == 1) {
                                    layer.msg('删除成功', {
                                        icon: 1
                                        , time: 1000
                                    }, function () {
                                        obj.del();
                                    });
                                }
                                else if (data.status == 0) {
                                    layer.msg('删除失败', {
                                        icon: 0
                                        , time: 1000
                                    });
                                }
                            },
                            error: function (result) {
                                console.log(result);
                                alert("系统繁忙！");
                            }
                        });
                    });
                }
            });
        } else if(obj.event === 'edit'){
            var tr = $(obj.tr);

            var index = layer.open({
                type: 2
                ,title: '编辑管理员'
                ,content: 'roleEdit?aId='+data.aId
                ,maxmin: true
                ,area: ['500px', '450px']
                ,btn: ['确定', '取消']
                ,yes: function(index, layero){
                    var iframeWindow = window['layui-layer-iframe'+ index]
                        ,submitID = 'LAY-front-submit'
                        ,submit = layero.find('iframe').contents().find('#'+ submitID);

                    //监听提交
                    iframeWindow.layui.form.on('submit('+ submitID +')', function(data){
                        var field = data.field; //获取提交的字段

                        //提交 Ajax 成功后，静态更新表格中的数据
                        $.ajax({
                            url: "editRole",
                            dataType: "json",
                            type: "post",
                            data: field,
                            success: function (data) {
                                if (data.status == 1) {
                                    layer.msg('编辑成功', {
                                        icon: 1
                                        , time: 1000
                                    }, function () {
                                        layer.close(index); //关闭弹层
                                        table.reload('LAY-role-manage'); //数据刷新
                                    });
                                }
                                else if (data.status == 0) {
                                    layer.msg('编辑失败', {
                                        icon: 0
                                        , time: 1000
                                    });
                                }
                            },
                            error: function (result) {
                                console.log(result);
                                alert("系统繁忙！");
                            }
                        });
                    });

                    submit.trigger('click');
                }
                ,success: function(layero, index){

                }
            });
            //如果手机端，全屏显示
            if(window.innerWidth <= 768) {
                layui.layer.full(index);
                setTimeout(function () {
                    layui.layer.tips('点击此处返回', '.layui-layer-setwin .layui-layer-close', {
                        tips: 3
                    });
                }, 500)
            }
        }
    });

  //评论管理
  table.render({
        elem: '#LAY-comment-manage'
        ,url: 'getComments'
        ,cols: [[
            {type: 'checkbox', fixed: 'left'}
            ,{field: 'cId', width: 70, title: 'ID', sort: true}
            ,{field: 'uname', title: '用户', minWidth: 100, sort: true, templet: '#userTpl'}
            ,{field: 'cFlag', title: '类型',sort: true, templet: '#flagTpl'}
            ,{field: 'cContent', minWidth: 100, title: '内容'}
            ,{field: 'cCid', title: '被评论者', sort: true, templet: '#user2Tpl'}
            ,{field: 'cTime', title: '时间', sort: true}
            ,{field: 'cRead', title: '已读',width: 100, sort: true, templet: '#readTpl'}
            ,{title: '操作', width: 150, align:'center', fixed: 'right', toolbar: '#table-useradmin-webuser'}
        ]]
        ,page: true
        ,limit: 30
        ,height: 'full-220'
        ,text: {none: '一条数据也没有^_^'}
    });

  //监听工具条
  table.on('tool(LAY-comment-manage)', function(obj){
        var data = obj.data,
            ids = [];
        ids.push(data.cId);
        if(obj.event === 'del'){
            layer.prompt({
                formType: 1
                ,title: '敏感操作，请验证密码'
            }, function(value, index){
                if (checkpass(value)) {
                    layer.close(index);
                    layer.confirm('真的删除当前评论么？', function (index) {
                        layer.close(index);
                        $.ajax({
                            url: "delComment",
                            dataType: "json",
                            type: "post",
                            data: {
                                ids: ids
                            },
                            success: function (data) {
                                if (data.status == 1) {
                                    layer.msg('删除成功', {
                                        icon: 1
                                        , time: 1000
                                    }, function () {
                                        obj.del();
                                    });
                                }
                                else if (data.status == 0) {
                                    layer.msg('删除失败', {
                                        icon: 0
                                        , time: 1000
                                    });
                                }
                            },
                            error: function (result) {
                                console.log(result);
                                alert("系统繁忙！");
                            }
                        });
                    });
                }
            });
        } else if(obj.event === 'look'){
            var tr = $(obj.tr);

            var index = layer.open({
                type: 2
                ,title: '评论详情'
                ,content: '/commentLook?cId='+data.cId
                ,maxmin: true
                ,area: ['400px', '600px']
                ,btn: ['确定']
            });
            //如果手机端，全屏显示
            if(window.innerWidth <= 768) {
                layui.layer.full(index);
                setTimeout(function () {
                    layui.layer.tips('点击此处返回', '.layui-layer-setwin .layui-layer-close', {
                        tips: 3
                    });
                }, 500)
            }
        }
    });


  //APP更新
  table.render({
      elem: '#LAY-update-manage'
      ,url: 'getUpdates'
      ,cols: [[
          {type: 'checkbox', fixed: 'left'}
          ,{field: 'uId', width: 70, title: 'ID', sort: true}
          ,{field: 'uVersion', width:120,title: '版本号',  sort: true}
          ,{field: 'uContent', title: '更新说明'}
          ,{field: 'uDownload', title: '下载链接',templet:function(d){
                  return '<a style="cursor: pointer;" href="'+d.uDownload+'">'+d.uDownload+'</a>';
          }}
          ,{field: 'uTime', title: '更新时间', sort: true}
          ,{field: 'uLimit', width:120,title: '最低版本'}
          ,{title: '操作', width: 150, align:'center', fixed: 'right', toolbar: '#table-useradmin-webuser'}
      ]]
      ,page: true
      ,limit: 30
      ,height: 'full-100'
      ,text: {none: '一条数据也没有^_^'}
  });

  //监听工具条
  table.on('tool(LAY-update-manage)', function(obj){
        var data = obj.data,
            ids = [];
        ids.push(data.uId);
        if(obj.event === 'del'){
            layer.prompt({
                formType: 1
                ,title: '敏感操作，请验证密码'
            }, function(value, index){
                if (checkpass(value)) {
                    layer.close(index);
                    layer.confirm('真的删除当前更新么？', function (index) {
                        layer.close(index);
                        $.ajax({
                            url: "delUpdate",
                            dataType: "json",
                            type: "post",
                            data: {
                                ids: ids
                            },
                            success: function (data) {
                                if (data.status == 1) {
                                    layer.msg('删除成功', {
                                        icon: 1
                                        , time: 1000
                                    }, function () {
                                        obj.del();
                                    });
                                }
                                else if (data.status == 0) {
                                    layer.msg('删除失败', {
                                        icon: 0
                                        , time: 1000
                                    });
                                }
                            },
                            error: function (result) {
                                console.log(result);
                                alert("系统繁忙！");
                            }
                        });
                    });
                }
            });
        } else if(obj.event === 'edit'){
            var tr = $(obj.tr);

            var index = layer.open({
                type: 2
                ,title: '编辑更新'
                ,content: 'updateEdit?uId='+data.uId
                ,maxmin: true
                ,area: ['500px', '450px']
                ,btn: ['确定', '取消']
                ,yes: function(index, layero){
                    var iframeWindow = window['layui-layer-iframe'+ index]
                        ,submitID = 'LAY-front-submit'
                        ,submit = layero.find('iframe').contents().find('#'+ submitID);

                    //监听提交
                    iframeWindow.layui.form.on('submit('+ submitID +')', function(data){
                        var field = data.field; //获取提交的字段

                        //提交 Ajax 成功后，静态更新表格中的数据
                        $.ajax({
                            url: "editUpdate",
                            dataType: "json",
                            type: "post",
                            data: field,
                            success: function (data) {
                                if (data.status == 1) {
                                    layer.msg('编辑成功', {
                                        icon: 1
                                        , time: 1000
                                    }, function () {
                                        layer.close(index); //关闭弹层
                                        table.reload('LAY-update-manage'); //数据刷新
                                    });
                                }
                                else if (data.status == 0) {
                                    layer.msg('编辑失败', {
                                        icon: 0
                                        , time: 1000
                                    });
                                }
                            },
                            error: function (result) {
                                console.log(result);
                                alert("系统繁忙！");
                            }
                        });
                    });

                    submit.trigger('click');
                }
                ,success: function(layero, index){

                }
            });
            //如果手机端，全屏显示
            if(window.innerWidth <= 768) {
                layui.layer.full(index);
                setTimeout(function () {
                    layui.layer.tips('点击此处返回', '.layui-layer-setwin .layui-layer-close', {
                        tips: 3
                    });
                }, 500)
            }
        }
    });

  //验证密码
  window.checkpass = function checkpass(pass){
    var result = false;
      $.ajax({
          url:"/admin/checkpass",
          dataType:"json",
          type:"post",
          async: false,
          data:{
              pass : pass
          },
          success:function(data){
              if (data.status==1) {
                  result = true;
              }
              else if (data.status==0) {
                  layer.msg('密码错误！');
              }
          },
          error:function(result){
              console.log(result);
              alert("系统繁忙！");
          }
      });
      return result ;
  }
  window.myimages = function(src){
      var height = window.screen.height,
          width = window.screen.width;
      var area = '800px';
      if (src.toString().substr(8,8)=="headicon")
          area = "500px";
      if (width<520) {
          area = '95%';
      }
        //图片预览
        top.layer.open({
            type: 1,
            title: false,
            closeBtn: 1,
            area: area,
            // maxWidth:width*0.95,
            // maxHeight:716,
            skin: 'layui-layer-nobg', //没有背景色
            shadeClose: true
            ,content: '<img src="'+src+'" width="100%" height="100%" style="">'
        });
    }
  exports('useradmin', {})
});